﻿/*----------------------------------------------------------------
 * 
 * 版权所有：Copyright (C) 2013
 * 
 * 文件名：AlbumConfiguration.cs
 * 文件功能描述：
 * 
 * 
 * 作 者：zhangq
 * 邮 箱：ifunnyface@outlook.com
 * 日 期：2013-03-04 16:03:26
 * 
 * 
 * 修改标识： Author
 * 修改描述： 相关描述
 * 
 * ---------------------------------------------------------------- */

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using DomainModel;

namespace Infrastructure.Mapper
{

    /// <summary>
    /// 
    /// </summary>
    public class AlbumConfiguration : EntityTypeConfiguration<AlbumInfo>
    {

        /// <summary>
        /// 
        /// </summary>
        public AlbumConfiguration()
        {
            ToTable("CTB_Albums");
            HasKey(m => m.AlbumId);
            Property(m => m.AlbumId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(m=>m.AlbumName).HasMaxLength(50);
            Property(m => m.CompanyId);

            //HasRequired(m => m.Company).WithMany().HasForeignKey(m => m.CompanyId);

            HasMany(m => m.Photos).WithRequired(m => m.Album).HasForeignKey(m=>m.AlbumId).WillCascadeOnDelete(true);
        }

         
    }

}